# 设置最低 CMake 版本
cmake_minimum_required ( VERSION 3.15 FATAL_ERROR )

# 定义项目名称和支持的语言
project ( recipe-07 LANGUAGES C CXX )

# 设置默认构建类型为 Release（如果未指定）
if ( NOT CMAKE_BUILD_TYPE )
    set ( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE )
endif ()

# 打印当前的构建类型
message ( STATUS "Build type: ${CMAKE_BUILD_TYPE}" )

# 打印不同构建类型的编译标志
message ( STATUS "C flags, Debug configuration: ${CMAKE_C_FLAGS_DEBUG}" )
message ( STATUS "C flags, Release configuration: ${CMAKE_C_FLAGS_RELEASE}" )
message ( STATUS "C flags, Release with Debug info: ${CMAKE_C_FLAGS_RELWITHDEBINFO}" )
message ( STATUS "C flags, Minimal Release configuration: ${CMAKE_C_FLAGS_MINSIZEREL}" )

message ( STATUS "C++ flags, Debug configuration: ${CMAKE_CXX_FLAGS_DEBUG}" )
message ( STATUS "C++ flags, Release configuration: ${CMAKE_CXX_FLAGS_RELEASE}" )
message ( STATUS "C++ flags, Release with Debug info: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
message ( STATUS "C++ flags, Minimal Release configuration: ${CMAKE_CXX_FLAGS_MINSIZEREL}" )

# PS D:\cmake_learn\07切换构建类型\build> cmake .. -G"Visual Studio 17 2022" -D CMAKE_CONFIGURATION_TYPES="Release;Debug"